<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 对象的新增方法

        // 1. Object.is()
        console.log(Object.is("abc", "abc")); //true
        console.log(Object.is([], [])); //false

        console.log(+0 === -0); //true
        console.log(Object.is(+0, -0)); //false

        // console.log([] == []);
        // console.log([] === []);
        // console.log({} === {});
        // console.log({} == {});

        //2. Object.assign() 对象合并
        const ob1 = {a:"AAA",b:"BBB",e:"EE1"}
        const ob2 = {c:"CCC",d:"DDD",e:"EE2"}
        const ob3 = {e:"EEE"}

        Object.assign(ob3,ob2,ob1);
        console.log(ob3);

        // 3. Object.getOwnPropertyDescriptors()
        // 返回指定对象所有自身属性（非继承属性）的描述对象
        const stu = {
            name:"zhangsan",
            age:20
        }
        console.log(Object.getOwnPropertyDescriptors(stu));
        stu.name = "lisi";


        // 4. __proto__属性，Object.setPrototypeOf()，Object.getPrototypeOf()
        // js是通过原型链来实现对象的继承
        const a = { a:"AAA" };
        const b = { b:"BBB" };

        // 获取b对象的原型对象
        console.log(b.__proto__);
        console.log(b.__proto__ === Object.prototype); // true
        console.log(Object.getPrototypeOf(b) === Object.prototype); // true

        // 让b继承a的原型
        //b.__proto__ = a;
        Object.setPrototypeOf(b, a); // 等价于上面的做法

        console.log(b.b);
        console.log(b.a);
        console.log(b);

        //5. Object.keys()，Object.values()，Object.entries()
        const stu2 = { name: "zhangsan", age: 20, classid: 'web0907' };

        console.log(Object.keys(stu2)); // 获取stu2对象的所有属性
        console.log(Object.values(stu2)); // 获取stu2对象的所有属性值
        console.log(Object.entries(stu2)); // 获取stu2对象所有（属性-值）对

    </script>
</body>
</html>